import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import { routers, anyRouter } from "./modules/routers"
import { views } from './modules/views'

// 读取.env配置文件的路由模式
const mode = import.meta.env.VITE_ROUTER_MODE

// 定义路由模式
const routeMode: any = {
  hash: () => createWebHashHistory(),
  history: () => createWebHistory()
}

// 创建路由对象
const router = createRouter({
  history: routeMode[mode](),
  routes: [...views, ...routers, ...anyRouter],
  // 滚动行为
  scrollBehavior() {
    return {
      left: 0,
      top: 0
    };
  }
})

export default router
